#include <stdio.h>
#include "StrategyInterface.h"

#ifndef _WIN32
#include "k.h"

#define KDBLEN 128

char* KDB_HOST = (char*)"localhost";
int KDB_PORT = 5009;

static int kdb_handle = khpu(KDB_HOST, KDB_PORT, (char*)"");
static char kdb_sql[KDBLEN];
#endif

void OnDepthMarketData_(CTShZdDepthMarketDataField * pDepthMarketData)
{
    printf("I am in OnDepthMarketData\n");
    TShZdDateType   TradingDay;
    ///合约代码  直达
    printf("InstrumentID:%s\n ", pDepthMarketData->InstrumentID);
    ///交易所代码   直达
    TShZdExchangeIDType ExchangeID;
    printf("ExchangeID:%s\n", pDepthMarketData->InstrumentID);
    printf("LastPrice:%f\n", pDepthMarketData->LastPrice);
    printf("PreSettlementPrice:%f\n", pDepthMarketData->PreSettlementPrice);
    printf("PreClosePrice:%f\n", pDepthMarketData->PreClosePrice);
    printf("OpenPrice:%f\n", pDepthMarketData->OpenPrice);
    printf("HighestPrice:%f\n", pDepthMarketData->HighestPrice);
    printf("LowestPrice:%f\n", pDepthMarketData->LowestPrice);
    printf("Volume:%d\n", pDepthMarketData->Volume);
    printf("Turnover:%d\n", pDepthMarketData->Turnover);
    printf("ClosePrice:%f\n", pDepthMarketData->ClosePrice);
    printf("UpdateTime:%s\n", pDepthMarketData->UpdateTime);
    printf("UpdateMillisec:%f\n", pDepthMarketData->UpdateMillisec);
    printf("BidPrice1:%f\n", pDepthMarketData->BidPrice1);
    printf("BidPrice2:%f\n", pDepthMarketData->BidPrice2);
    printf("BidPrice3:%f\n", pDepthMarketData->BidPrice3);
    printf("BidPrice4:%f\n", pDepthMarketData->BidPrice4);
    printf("BidPrice5:%f\n", pDepthMarketData->BidPrice5);
    printf("AskPrice1:%f\n", pDepthMarketData->AskPrice1);
    printf("AskPrice2:%f\n", pDepthMarketData->AskPrice2);
    printf("AskPrice3:%f\n", pDepthMarketData->AskPrice3);
    printf("AskPrice4:%f\n", pDepthMarketData->AskPrice4);
    printf("AskPrice5:%f\n", pDepthMarketData->AskPrice5);
    printf("BidVolume1:%d\n", pDepthMarketData->BidVolume1);
    printf("BidVolume2:%d\n", pDepthMarketData->BidVolume2);
    printf("BidVolume3:%d\n", pDepthMarketData->BidVolume3);
    printf("BidVolume4:%d\n", pDepthMarketData->BidVolume4);
    printf("BidVolume5:%d\n", pDepthMarketData->BidVolume5);
    printf("AskVolume1:%d\n", pDepthMarketData->AskVolume1);
    printf("AskVolume2:%d\n", pDepthMarketData->AskVolume2);
    printf("AskVolume3:%d\n", pDepthMarketData->AskVolume3);
    printf("AskVolume4:%d\n", pDepthMarketData->AskVolume4);
    printf("AskVolume5:%d\n", pDepthMarketData->AskVolume5);
    //sprintf(kdb_sql,"ZdLastPrice:%g;",pDepthMarketData->LastPrice);

#ifndef _WIN32
    sprintf(kdb_sql,"ZdAskPrice:%g;ZdBidPrice:%g",pDepthMarketData->AskPrice1,pDepthMarketData->BidPrice1);
    k(kdb_handle,kdb_sql,(K)0);
#endif
}

void OnRtnFilledMarketData_(CTShZdFilledDataField * pFilledMarketData)
{
    printf("I am in OnRtnFilledMarketData\n");
}

